/** \file gu_vertex_signature.h */
#pragma once

#include <map>
#include <vector>
#include<cstdint>

namespace gu{

//TODO: move to gr as gr_streams or something

/** Reference to a stream data such as vertex buffer. This is semantically different from
 *  the shader variable type. They might be identical, or, for example in the case of uniform
 *  matrices, not.*/
enum StreamType
{
    STREAM_FLOAT4
};

size_t streamTypeSize(StreamType type);

/** Contains signature of single vertex */
struct StreamChannelInfo
{
    StreamType vertexType;
    size_t offset;     //> At what offset does the vertex data start
    std::string name;
};

StreamChannelInfo streamChannelInfo(StreamType vertexType, uint32_t offset, const char* name);


class StreamSignature
{
public:

    typedef std::vector<StreamChannelInfo> SignatureArray;
    size_t vertexSize_;
    SignatureArray vertices_;
    StreamSignature():vertexSize_(0){}
    void add(StreamType type, const char* name)
    {
        size_t offset = vertexSize_;
        vertexSize_ += streamTypeSize(type);
        vertices_.push_back(streamChannelInfo(type, offset, name));
    }
    SignatureArray::iterator begin(){return vertices_.begin();}
    SignatureArray::iterator end(){return vertices_.end();}
    size_t vertexSize(){return vertexSize_;}
};


}
